gtk/main: Toggle active flag with touch events
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 12 Nov 2020 16:31:52 +0000 (17:31 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 12 Nov 2020 23:39:23 +0000 (00:39 +0100)
This went missing at some point, add the missing toggling of active
state with GDK_TOUCH_BEGIN/END/CANCEL events.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3348
gtk/gtkmain.c

index cfc74ce43e8571c3819a0934086e97346ea63b2f..96ff1e69ad485d32e53691016edb04835c7195ad 100644 (file)
@@ -1413,7 +1413,9 @@ handle_pointing_event (GdkEvent *event)
     case GDK_TOUCH_END:
     case GDK_TOUCH_CANCEL:
       old_target = update_pointer_focus_state (toplevel, event, NULL);
-      if (type == GDK_LEAVE_NOTIFY)
+      if (type == GDK_TOUCH_END || type == GDK_TOUCH_CANCEL)
+        set_widget_active_state (old_target, TRUE);
+      else if (type == GDK_LEAVE_NOTIFY)
         gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, old_target, NULL,
                                         event, gdk_crossing_event_get_mode (event), NULL);
       break;
@@ -1465,7 +1467,10 @@ handle_pointing_event (GdkEvent *event)
           gtk_drop_end_event (drop);
         }
       else if (type == GDK_TOUCH_BEGIN)
-        gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
+        {
+          gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
+          set_widget_active_state (target, FALSE);
+        }
 
       /* Let it take the effective pointer focus anyway, as it may change due
        * to implicit grabs.